<template>
  <div id="app">
    <h1>在线翻译</h1>
    <h5 class="text-muted">简单/易用/便捷</h5>
    <translateFrom v-on:formSubmit="translateText"></translateFrom>
    <translateOutput v-text="translatedText"></translateOutput>
    <p class="text-muted copyright">@版权-陈登所有-允许侵权</p>
  </div>
</template>

<script>
  import TranslateFrom from './components/TranslateFrom';
  import TranslateOutput from './components/TranslateOutput';

export default {
  name: 'app',
  data:function () {
    return{
        translatedText:''
    }
  },
  components:{
    TranslateFrom,TranslateOutput
  },
  methods:{
    translateText:function (text,language) {
//        alert(text);
      this.$http.get('https://translate.yandex.net/api/v1.5/tr.json/translate?key=trnsl.1.1.20170826T080730Z.6b1aa42814a968d9.5f27439febdf406c92279416a34da70fcdf47282&lang='+language+'&text='+text)
        .then((response)=>{
//            console.log(response.body.text[0]);
            this.translatedText=response.body.text[0]
        })
      }
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
  .copyright{
    margin-top: 100px;
  }
</style>
